home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tcl_CreateCommand C Library Procedures Tcl_CreateCommand
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Tcl_CreateCommand, Tcl_DeleteCommand - define application-
- specific command bindings
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ttccll..hh>>
-
- TTccll__CCrreeaatteeCCoommmmaanndd(_i_n_t_e_r_p, _c_m_d_N_a_m_e, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a, _d_e_l_e_t_e_P_r_o_c)
-
- int
- TTccll__DDeelleetteeCCoommmmaanndd(_i_n_t_e_r_p, _c_m_d_N_a_m_e)
-
- AARRGGUUMMEENNTTSS
- Tcl_Interp *_i_n_t_e_r_p (in) Interpreter
- in which to
- create new
- command.
-
- char *_c_m_d_N_a_m_e (in) Name of com-
- mand to
- create or
- delete.
-
- Tcl_CmdProc *_p_r_o_c (in) Implementation
- of new com-
- mand: _p_r_o_c
- will be
- called when-
- ever _c_m_d_N_a_m_e
- is invoked
- as a com-
- mand.
-
- ClientData _c_l_i_e_n_t_D_a_t_a (in) Arbitrary
- one-word
- value to
- pass to _p_r_o_c
- and
- _d_e_l_e_t_e_P_r_o_c.
-
- Tcl_CmdDeleteProc *_d_e_l_e_t_e_P_r_o_c (in) Procedure to
- call before
- _c_m_d_N_a_m_e is
- deleted from
- the inter-
- preter;
- allows for
- command-
- specific
- cleanup. If
-
-
-
- Sprite v1.0 1
-
-
-
-
-
-
- Tcl_CreateCommand C Library Procedures Tcl_CreateCommand
-
-
-
- NULL, then
- no procedure
- is called
- before the
- command is
- deleted.
- _________________________________________________________________
-
-
- DDEESSCCRRIIPPTTIIOONN
- TTccll__CCrreeaatteeCCoommmmaanndd defines a new command in _i_n_t_e_r_p and asso-
- ciates it with procedure _p_r_o_c such that whenever _c_m_d_N_a_m_e is
- invoked as a Tcl command (via a call to TTccll__EEvvaall) the Tcl
- interpreter will call _p_r_o_c to process the command. If there
- is already a command _c_m_d_N_a_m_e associated with the inter-
- preter, it is deleted. _P_r_o_c should have arguments and
- result that match the type TTccll__CCmmddPPrroocc:
- typedef int Tcl_CmdProc(
- ClientData _c_l_i_e_n_t_D_a_t_a,
- Tcl_Interp *_i_n_t_e_r_p,
- int _a_r_g_c,
- char *_a_r_g_v[]);
- When _p_r_o_c is invoked the _c_l_i_e_n_t_D_a_t_a and _i_n_t_e_r_p parameters
- will be copies of the _c_l_i_e_n_t_D_a_t_a and _i_n_t_e_r_p arguments given
- to TTccll__CCrreeaatteeCCoommmmaanndd. Typically, _c_l_i_e_n_t_D_a_t_a points to an
- application-specific data structure that describes what to
- do when the command procedure is invoked. _A_r_g_c and _a_r_g_v
- describe the arguments to the command, _a_r_g_c giving the
- number of arguments (including the command name) and _a_r_g_v
- giving the values of the arguments as strings. The _a_r_g_v
- array will contain _a_r_g_c+1 values; the first _a_r_g_c values
- point to the argument strings, and the last value is NULL.
-
- _P_r_o_c must return an integer code that is either TTCCLL__OOKK,
- TTCCLL__EERRRROORR, TTCCLL__RREETTUURRNN, TTCCLL__BBRREEAAKK, or TTCCLL__CCOONNTTIINNUUEE. See the
- Tcl overview man page for details on what these codes mean.
- Most normal commands will only return TTCCLL__OOKK or TTCCLL__EERRRROORR.
- In addition, _p_r_o_c must set _i_n_t_e_r_p->_r_e_s_u_l_t to point to a
- string value; in the case of a TTCCLL__OOKK return code this gives
- the result of the command, and in the case of TTCCLL__EERRRROORR it
- gives an error message. The TTccll__SSeettRReessuulltt procedure pro-
- vides an easy interface for setting the return value; for
- complete details on how the _i_n_t_e_r_p->_r_e_s_u_l_t field is managed,
- see the TTccll__IInntteerrpp man page. Before invoking a command pro-
- cedure, TTccll__EEvvaall sets _i_n_t_e_r_p->_r_e_s_u_l_t to point to an empty
- string, so simple commands can return an empty result by
- doing nothing at all.
-
- The contents of the _a_r_g_v array are copies made by the Tcl
- interpreter for the use of _p_r_o_c. _P_r_o_c may alter any of the
- strings in _a_r_g_v. However, the _a_r_g_v array is recycled as
- soon as _p_r_o_c returns, so _p_r_o_c must not set _i_n_t_e_r_p->_r_e_s_u_l_t to
-
-
-
- Sprite v1.0 2
-
-
-
-
-
-
- Tcl_CreateCommand C Library Procedures Tcl_CreateCommand
-
-
-
- point anywhere within the _a_r_g_v values (call Tcl_SetResult
- with status TTCCLL__VVOOLLAATTIILLEE if you want to return something
- from the _a_r_g_v array).
-
- _D_e_l_e_t_e_P_r_o_c will be invoked when (if) _c_m_d_N_a_m_e is deleted.
- This can occur through a call to TTccll__DDeelleetteeCCoommmmaanndd or
- TTccll__DDeelleetteeIInntteerrpp, or by replacing _c_m_d_N_a_m_e in another call to
- Tcl_CreateCommand. _D_e_l_e_t_e_P_r_o_c is invoked before the command
- is deleted, and gives the application an opportunity to
- release any structures associated with the command.
- _D_e_l_e_t_e_P_r_o_c should have arguments and result that match the
- type TTccll__CCmmddDDeelleetteePPrroocc:
-
- typedef void Tcl_CmdDeleteProc(ClientData _c_l_i_e_n_t_D_a_t_a);
-
- The _c_l_i_e_n_t_D_a_t_a argument will be the same as the _c_l_i_e_n_t_D_a_t_a
- argument passed to TTccll__CCrreeaatteeCCoommmmaanndd.
-
- TTccll__DDeelleetteeCCoommmmaanndd deletes a command from a command inter-
- preter. Once the call completes, attempts to invoke _c_m_d_N_a_m_e
- in _i_n_t_e_r_p will result in errors. If _c_m_d_N_a_m_e isn't bound as
- a command in _i_n_t_e_r_p then TTccll__DDeelleetteeCCoommmmaanndd does nothing and
- returns -1; otherwise it returns 0. There are no restric-
- tions on _c_m_d_N_a_m_e: it may refer to a built-in command, an
- application-specific command, or a Tcl procedure.
-
-
- KKEEYYWWOORRDDSS
- bind, command, create, delete, interpreter
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v1.0 3
-
-
-
-